from PyQt4 import QtCore, QtGui

class Wizard(QtGui.QWidget):
    def __init__(self):
        QtGui.QWidget.__init__(self, None)
        self.pages = []
        self.tabcontainer = QtGui.QStackedLayout()
        self.mainLayout = QtGui.QVBoxLayout()
        self.mainLayout.addLayout(self.tabcontainer)
        self.setLayout(self.mainLayout)
        self.index = 0

    def add_page(self, widget):
        #widget.setParent(self)
        #widget.setEnabled(False)
        self.tabcontainer.addWidget(widget)
        self.pages.append(widget)
        #if len(self.pages) > 1:
         #   widget.hide()
        self.connect(widget, QtCore.SIGNAL("clicked()"), self.changePage)
    
    def changePage(self):
        self.index = self.index + 1
        if self.index >= len(self.pages):
            self.index = 0
        self.tabcontainer.setCurrentIndex(self.index)

class Page(QtGui.QWidget):
    def __init__(self, text):
        self.text = text
        QtGui.QWidget.__init__(self, None)
        button = QtGui.QPushButton(text)
        self.connect(button, QtCore.SIGNAL("clicked()"), self.print_text)
        #label = QtGui.QLabel(text,self)
        self.container = QtGui.QVBoxLayout()
        self.container.addWidget(button)
        self.container.addWidget(QtGui.QLabel(text))
        self.setLayout(self.container)

    
    def print_text(self):
        print "Clicked %s" % self.text
        self.emit(QtCore.SIGNAL("clicked()"))
        self.hide()
        

if __name__=="__main__":
    args = []
    application = QtGui.QApplication(args)
    wizard = Wizard()
    wizard.setWindowFlags(QtCore.Qt.FramelessWindowHint)
    wizard.add_page(Page("Test 1"))
    wizard.add_page(Page("Test 2"))
    print "CHILED %s " % len(wizard.children())
    wizard.show()
    application.exec_()